package io.awen.modules.sign.controller;

import io.awen.common.utils.PageUtils;
import io.awen.common.utils.R;
import io.awen.modules.sign.entity.SignContainerAlarmEntity;
import io.awen.modules.sign.qo.SignContainerAlarmQo;
import io.awen.modules.sign.service.SignContainerAlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 报警信息记录表
 *
 * @author liu.wen
 * @email liu.wen@qq.com
 * @date 2022-08-10 00:47:08
 */
@RestController
@RequestMapping("/sign/signcontaineralarm")
public class SignContainerAlarmController {
    @Autowired
    private SignContainerAlarmService signContainerAlarmService;

    /**
     * 按条件查询 报警 总数
     * @param qo
     * @return
     */
    @PostMapping("/total")
    public R total(@RequestBody SignContainerAlarmQo qo){
        int total = signContainerAlarmService.total(qo);
        return R.ok().put("total", total);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sign:signcontaineralarm:list")
    public R list(@RequestBody SignContainerAlarmQo qo){
        PageUtils page = signContainerAlarmService.queryPage(qo);

        return R.ok().put("page", page);
    }


    @RequestMapping("/listOfNoFinish")
//    @RequiresPermissions("sign:signcontaineralarm:list")
    public R listOfNoFinish(@RequestBody SignContainerAlarmQo qo){
        PageUtils page = signContainerAlarmService.queryPageOfNoFinsih(qo);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sign:signcontaineralarm:info")
    public R info(@PathVariable("id") Long id){
		SignContainerAlarmEntity signContainerAlarm = signContainerAlarmService.getById(id);

        return R.ok().put("signContainerAlarm", signContainerAlarm);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sign:signcontaineralarm:save")
    public R save(@RequestBody SignContainerAlarmEntity signContainerAlarm){
		signContainerAlarmService.save(signContainerAlarm);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sign:signcontaineralarm:update")
    public R update(@RequestBody SignContainerAlarmEntity signContainerAlarm){
		signContainerAlarmService.updateById(signContainerAlarm);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sign:signcontaineralarm:delete")
    public R delete(@RequestBody Long[] ids){
		signContainerAlarmService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
